package com.zhudeshuai.zhudemolist.activity;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.MotionEvent;

import com.zhu.zhuCore.log.Logger;
import com.zhudeshuai.zhudemolist.R;
import com.zhudeshuai.zhudemolist.base.BaseActivity;

/**
 * @author zhudeshuai
 * @since 16/5/29
 */
public class TouchDemoActivity extends BaseActivity {
    private static final String TAG = "TouchDemoActivity";

    private Logger mLogger = new Logger(TAG);

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_touch_demo);
    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        mLogger.d(TAG, this.getClass().getSimpleName() + " : onTouchEvent," + getAction(event));
        return super.onTouchEvent(event);
    }

    private String getAction(MotionEvent event) {
        String resultAction = "";
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                resultAction = "ACTION_DOWN";
                break;
            case MotionEvent.ACTION_MOVE:
                resultAction = "ACTION_MOVE";
                break;
            case MotionEvent.ACTION_UP:
                resultAction = "ACTION_UP";
                break;
        }
        return resultAction;
    }

    @Override
    public boolean dispatchTouchEvent(MotionEvent event) {
        mLogger.d(TAG, this.getClass().getSimpleName() + " : dispatchTouchEvent," + getAction(event));
        return super.dispatchTouchEvent(event);
    }

    public static void open(Activity activity) {
        activity.startActivity(new Intent(activity,TouchDemoActivity.class));
    }
}
